import { reactive } from "vue";
import type { FormRules } from "element-plus";
import { isPhone, isEmail } from "@pureadmin/utils";
/** 自定义表单规则校验 */
export const formRules = reactive(<FormRules>{
	projectId: [{ required: true, message: "所属项目为必填项", trigger: "change" }],
	taskType: [{ required: true, message: "任务类型为必填项", trigger: "change" }],
	assignedTo: [{ required: true, message: "指派用户为必填项", trigger: "change" }],
	rangePlanDate: [{ required: true, message: "计划日期为必填项", trigger: "change" }],
	priority: [{ required: true, message: "优先级为必填项", trigger: "blur" }],
	expectHour: [{ required: true, message: "预计小时为必填项", trigger: "blur" }],
	description: [{ required: true, message: "描述为必填项", trigger: "blur" }],
	keyword: [{ required: true, message: "关键词为必填项", trigger: "blur" }],
	assignedExtraTo: [{ required: true, message: "抄送用户为必填项", trigger: "change" }],
	completeRate: [{ required: true, message: "完成比例为必填项", trigger: "blur" }],
  status: [{ required: true, message: "状态为必填项", trigger: "change" }],
  isVat: [{ required: true, message: "是否增值税发票为必填项", trigger: "change" }],
  title: [{ required: true, message: "发票抬头名称为必填项", trigger: "blur" }],
  content: [{ required: true, message: "发票抬头内容为必填项", trigger: "blur" }],
  amount: [{ required: true, message: "发票金额为必填项", trigger: "blur" }],
  taxNo: [{ required: true, message: "发票税号为必填项", trigger: "blur" }],
  tax: [{ required: true, message: "开票税金为必填项", trigger: "blur" }],
  companyName: [{ required: true, message: "公司名称为必填项", trigger: "blur" }],
  companyAddress: [{ required: true, message: "公司地址为必填项", trigger: "blur" }],
  telephone: [{ required: true, message: "联系电话为必填项", trigger: "blur" },
  {
  	validator: (rule, value, callback) => {
  		if (value === "") {
  			callback();
  		} else if (!isPhone(value)) {
  			callback(new Error("请输入正确的手机号码格式"));
  		} else {
  			callback();
  		}
  	},
  	trigger: "blur"
  }],
  bankName: [{ required: true, message: "开户银行为必填项", trigger: "blur" }],
  bankAccount: [{ required: true, message: "银行帐号为必填项", trigger: "blur" }],
  receiptFull: [{ required: true, message: "收款标识为必填项", trigger: "change" }],
});
